package io.github.kouleen.manager.listener.server;

import io.github.kouleen.minecraft.core.lang.annotation.MinecraftPluginListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServiceRegisterEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;

/**
 * 当一个服务被注册到服务器的服务管理器时，会触发该事件
 * @author zhangqing
 * @since 2025/2/26 11:07
 */
@MinecraftPluginListener
public class ServiceRegisterListener implements Listener {

    @EventHandler
    public void onServiceRegisterListener(ServiceRegisterEvent serviceRegisterEvent){
        RegisteredServiceProvider<?> registerEventProvider = serviceRegisterEvent.getProvider();
        Plugin providerPlugin = registerEventProvider.getPlugin();
        PluginDescriptionFile pluginDescriptionFile = providerPlugin.getDescription();
        System.out.println(providerPlugin.getName() + pluginDescriptionFile.getVersion() + "服务被注册");
    }
}
